import './assets/main.css'

import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import router from './router'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
// 引入 Element Plus 的暗黑模式样式
import 'element-plus/theme-chalk/dark/css-vars.css'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import mitt from 'mitt' // 引入 mitt 事件总线

const app = createApp(App)
const pinia = createPinia()

// 创建事件总线
const emitter = mitt()
// 将事件总线添加到全局属性
app.config.globalProperties.emitter = emitter
// 添加到全局变量，方便在组合式 API 中使用
window.emitter = emitter

// 注册所有图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

app.use(router)
app.use(ElementPlus, {
  locale: zhCn
})
app.use(pinia)

app.mount('#app')
